﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Microsoft.Practices.Unity;

namespace Isha.Web.Mvc
{
    public class IshaRequestContext
    {
        HttpContext _httpContext = null;

        public IshaRequestContext(HttpContext httpContext)
        {
            _httpContext = httpContext;
        }

        public string URL
        {
            get
            {                
                return _httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(2)
                                                + _httpContext.Request.PathInfo.ToLower().Trim();
            }
        }        

        public bool IsAllowed
        {
            get;
            set;
        }

        public bool IsFactoryAllowed
        {
            get;
            set;
        }

        public FormCollection FormCollection
        {
            get
            {
                return DependencyResolver.Current.GetService<FormCollection>();
            }
            internal set
            {
                IshaContext.Current.Container.RegisterInstance<FormCollection>(value);
            }
        }

        public bool IsAuthenticated
        {
            get
            {
                return _httpContext.Request.IsAuthenticated;
            }
        }
    }
}
